#include "uhm/common.hxx"
#include "uhm/util.hxx"

#include "uhm/discrete/base.hxx"

#include "uhm/discrete/extension/mesh2cache.hxx"


#define N 1
#define T 3

using namespace uhm;


typedef ID_Node_<N>              Id_Nd;
typedef ID_Element_<N>           Id_El;
typedef Int_                     Uhm;

typedef Mesh_<Id_Nd,Id_El,Uhm>   Mesh;
typedef Cache_<Id_Nd, Uhm>       Cache;

int main (int argc, char **argv) {

  Mesh::_Id_El_ el;
  Mesh::_Id_Nd_ nd;

  Mesh mesh;
  Mesh::Node_* n;
  Mesh::Element_* e;

  el.set_id(0, 10); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 0); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 1); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  el.set_id(0, 20); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 2); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  el.set_id(0, 30); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 5); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  el.set_id(0, 40); e = mesh.add_element(el);
  e->push_begin();
  nd.set_id(0, 1); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 3); n = mesh.add_node(nd); e->push(n);
  nd.set_id(0, 4); n = mesh.add_node(nd); e->push(n);
  e->push_end();

  std::cout << mesh << std::endl;

  Cache cache;
  mesh2cache<Mesh,Cache>(mesh, cache);

  std::cout << cache << std::endl;

  return true;
}


